package com.tenentia.pcmps.swm.business.implementation;

import java.util.List;

import org.apache.log4j.Logger;

import com.tenentia.pcmps.swm.Constants;
import com.tenentia.pcmps.swm.business.BusinessLogicException;
import com.tenentia.pcmps.swm.business.interfaces.WayTypesManager;
import com.tenentia.pcmps.swm.data.DataAccessObjectsFactory;
import com.tenentia.pcmps.swm.data.beans.WayType;
import com.tenentia.pcmps.swm.data.interfaces.WayTypesDAO;

/**
 * 
 * @author tEnEntia, S.L.N.E.
 * 
 */
public class WayTypesManagerImpl implements WayTypesManager {

	private static final Logger LOGGER = Logger.getLogger(WayTypesManagerImpl.class.getPackage().getName());
	
	public WayTypesManagerImpl() {
		super();
	}

	@Override
	public WayType get(WayType wayType) throws BusinessLogicException {
		LOGGER.debug(Constants.STRING_L4J_METHOD_BEGIN);

		try {
			WayTypesDAO dataAccessObject = (WayTypesDAO) DataAccessObjectsFactory.getInstance().createNewDataAccessObject(DataAccessObjectsFactory.WAY_TYPES_DAO);
			return dataAccessObject.get(wayType);
		} catch (Exception e) {
			LOGGER.error(e, e);
			throw new BusinessLogicException(e);
		}
	}

	@Override
	public List<WayType> getAvailableWayTypes() throws BusinessLogicException {
		LOGGER.debug(Constants.STRING_L4J_METHOD_BEGIN);

		try {
			WayTypesDAO dataAccessObject = (WayTypesDAO) DataAccessObjectsFactory.getInstance().createNewDataAccessObject(DataAccessObjectsFactory.WAY_TYPES_DAO);
			return dataAccessObject.getAvailableWayTypes();
		} catch (Exception e) {
			LOGGER.error(e, e);
			throw new BusinessLogicException(e);
		}
	}

}
